class Solution {
public:
    string addStrings(string num1, string num2) {
    //   9999    3 Longdex 
    //  999  2   Littledex
    //    _ _ _ _ _
        int long_dex = num1.size();
        int little_dex = num2.size();
        int ret = 0;
        int next = 0;
        if(long_dex < little_dex){
            num1.swap(num2);
            swap(long_dex, little_dex);
        }
        string str(long_dex + 1, '0');
        int end1 = long_dex - 1;
        int end2 = little_dex - 1;
        for(; end1 >= 0; end1--, end2--){
            ret = num1[end1] - '0' + next;
            if(end2 >= 0)
                ret += num2[end2] - '0';
            next = 0;
            if(ret > 9){
                next = 1;
                ret -= 10;
            }  
            str[end1 + 1] = ret + '0';
        }
        if(next == 1)
            str[0] = '1';
        else
            str.erase(str.begin());
            return str;
    }
};